<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>客房管理</title>
    <link href="<{$ipath}>user/style/my_service_css.css" type="text/css" rel="stylesheet">
    <link href="<{$ipath}>app/hotel/style/room_css.css" type="text/css" rel="stylesheet">
    <style>
		.button{font-size:14px;}.button a.quxiao{background-color:#f06a28;color:#fff;height:30px;line-height:30px;width:100px;text-align:center;}
        .shiyong i{
            background-image: url("<{$ipath}>app/hotel/images/room_management.png");
            background-repeat: no-repeat;
            display: inline-block;
            vertical-align: middle;
        }
        .close_f_x{
            background-position: 0 -465px;
            height: 20px;
            right: 6px;
            top: 6px;
            width: 20px;
        }
    </style>
   <script src="<{$ipath}>public/js/jquery.js"></script>
    <script type="text/javascript"  src="<{$ipath}>wx/js/ajaxfileupload.js"></script>
 <script>
        $(document).ready(function(e) {
            /*右上角x*/
            $(".click_span_02").click(function(){
				if(!$(this).hasClass('on')){
					$(this).addClass('on');
					$(".xianshi_02 .close_x:not(:first)").show();
				}else{
					$(this).removeClass('on');
					$(".xianshi_02 .close_x").hide();
				}
            });
            $(".click_span_03").click(function(){
				if(!$(this).hasClass('on')){
					$(this).addClass('on');
					$(".xianshi_03 .close_x").show();
				}else{
					$(this).removeClass('on');
					$(".xianshi_03 .close_x").hide();
				}
            });
            $(".click_span_04").click(function(){
                $(".xianshi_04 .close_x").show();
            });
            $(".click_span_05").click(function(){
                $(".xianshi_05 .close_x").show();
            });
            /*div鼠标经过和点击事件*/
            $(".tab_content ul li div").mousemove(function(){
                $(this).addClass("add_hover");
            });
            $(".tab_content ul li div").mouseleave(function(){
                $(this).removeClass("add_hover");
            });

            
            $(".input_jia").click(function(){
                var addText=$(".zidingyi").val();
                var url = '?m=manage&a=addFac';
                var data = {
                    'facname':addText
                };
                $.post(url,data,function(data){
                    if(data.stat==1) {
                        var str = '<span class="shiyong"><input type="checkbox" name="fac_list[]" value="'+data.msg+'">' + addText + '<i onclick="delfac('+data.msg+',this)" class="close_f_x"></i></span>';
                        $(".shiyong:last").after(str);
                        $(".zidingyi").val('自定义');
                    }
                },'json');
            })
        });
    function uploadimgs(){
        var url = "?m=manage&a=uploadimg";
        $.ajaxFileUpload({
            url:url,
            dataType:'json',
            fileElementId:'uploadimg',
            type:'post',
            secureuri:false,
            success:function(data){
                if(data.status==1){
                    alert('上传成功');
                    $('#logourl').val(data.msg);
                }else{
                    alert(data.msg);
                    return false;
                }
            }
        });
    };
    </script>
</head>

<body>
<div class="servicebox">
    <!--内容-->
    <P class="caption">当前位置 | 酒店管理 > 客房管理</P>
    <div class="content01">
    	<div class="caibox">
        <p class="title p_02">客房管理 <span class="neizhi"> | 按房型</span></p>
        <!--内容94%-->
        <div class="roombox">
            <!--3大mune-->
            <ul class="room_menu">
                <li class="li_right moren_li li_01 no_click"><a href="?m=manage&a=getRoomsByFtId" style="color:#fff;"><i class="i04"></i>按楼层</a></li>
                <li class="li_right li_02 click_green"><a href="javascript:window.location.reload();" style="color:#61c6d0;"><i class="i05"></i>按房型</a></li>
                <li class="li_03 no_click"><a href="?m=manage&a=setPro" style="color:#fff;"><i class="i03"></i>设置房价</a></li>
            </ul>

            <!--tab内容-->
            <div class="tab_content">
                <!--按房型-->
                <div class="floor">

                    <!--选择房型-->
                    <p class="type_p">
                        <span class="span01"><i class="type_icon"></i>选择房型</span>
                        <span class="span02 click_span_02" title="点击可进行删除操作"><i class="set_icon"></i>设置</span>
                    </p>
                    <ul class="house_ul xianshi_02">
                        <li>
                            <div class="<{if (isset($pam.tid) && $pam.tid=='0') || !isset($pam.tid)}>add_active<{/if}>">全部<i class="close_x" style="display:none;"></i></div>
                        </li>
                        <{foreach from=$types item=vv key=kk}>
                        <li id="t_<{$vv.id}>">
                            <div <{if isset($pam.tid) && $pam.tid==$vv.id}>class="add_active"<{/if}>><{$vv.name}><i class="close_x" style="display:none;"></i></div>
                        </li>
                        <{/foreach}>
                        <li id="addtypes">
                            <div class="add_room_box add_type01" onclick="getheigth(this,'.zong_tan01')"><i class="add_room"></i>添加房型</div>
                        </li>
                    </ul>
                    <!--选择房间-->
                    <p class="type_p room_top">
                        <span class="span01"><i class="type_icon_02"></i>选择房间</span>
                        <span class="span02 click_span_03" title="点击可进行删除操作"><i class="set_icon"></i>设置</span>
                    </p>
                    <ul class="room_ul xianshi_03">
                        <{foreach from=$rooms item=mm key=nn}>
                        <li id='r_<{$mm.id}>'>
                            <div>
                                <i class='close_x' style="display:none;"></i><span class='room_num'><{$mm.name}></span><P><span class='room_type'><{$mm.tname}></span></P>
                            </div>
                        </li>
                        <{/foreach}>
                        <li class="room_ul_li_add" id="addrooms">
                            <div class="add_room_box add_rooms01" onclick="getheigth(this,'.zong_tan02')"><i class="add_room"></i>添加房间</div>
                        </li>
                    </ul>
                </div>

            </div>
        </div>
		</div>
    </div>

</div>
<div class="zong_tan popup" style="display:none;">
<form action="?m=manage&a=addFloor" method="post">
<div class="add_floor close_back" id="add_floor">
    
</div>
<div class="floor_tan">
        <div class="floor_top">添加楼层<a href="javascript:;" class="cd-popup-close" ><i class="floor_close quxiao" id="floor_close"></i></a></div>
        <div class="floor_content">
            <div class="nei_content">
                <div class="div_01">
                    <span>楼层:</span>
                    <input type="text" name="num" id="fnum" class="tan_input">
                </div>
                <div class="div_02 div_01">
                    <p style="p_position">备注:</p>
                    <textarea type="text" name="remark" id="fremark" class="tan_input"></textarea>
                </div>
                <div class="button">
                    <button class="button01" type="submit">保存</button>
                    <a class="quxiao">取消</a>
                </div>
            </div>
        </div>
    </div>
</form>
</div>
<!--添加房型-->
<div class="zong_tan01 popup"  style="display:none;">
<form action="?m=manage&a=addHotelType" method="post">
<div class="add_type close_back" id="add_type">
    
</div>
<div class="floor_tan">
        <div class="floor_top">添加房型<a href="javascript:;" class="cd-popup-close" ><i class="floor_close quxiao" id="floor_close"></i></a></div>
        <div class="floor_content">
            <div class="nei_content">
                <div class="div_01">
                    <span>房型:</span>
                    <input type="text" name="name" id="tname" class="tan_input">
                </div>
                <div class="div_01">
                    <span>面积:</span>
                    <input type="text" name="tarea" id="tarea" class="tan_input"> m²
                </div>
                <div class="div_01">
                    <span>上传图片:</span>
                    <input type="type" name="logourl" readonly id="logourl" class="tan_input" style="width: 350px"/>
                    <input type="file" id="uploadimg" name="uploadimg" class="input_file01" onchange="uploadimgs()">
                </div>
                <div class="div_02 div_01">
                    <p style="p_position">备注:</p>
                    <textarea type="text" name="remark" id="tremark" class="tan_input"></textarea>
                </div>
                <input type="hidden" value="2" name="linktype"/>
                <div class="button">
                    <button class="button01" type="submit">保存</button>
                    <a class="quxiao">取消</a>
                </div>
            </div>
        </div>
    </div>
</form>
</div>
<!--添加房间-->
<div class="zong_tan02 popup"  style="display:none;">
<form action="?m=manage&a=addRoom" method="post" onsubmit="return formcheck();">
<div class="add_rooms close_back" id="add_rooms">
    
</div>
<div class="floor_tan">
        <div class="floor_top">添加房间<a href="javascript:;" class="cd-popup-close"><i class="floor_close quxiao" id="floor_close"></i></a></div>
        <div class="floor_content">
            <div class="nei_content">
                <div class="div_01">
                    <span>房号:</span>
                    <input type="text" name="name" id="rname" class="tan_input">
                    <span>楼层:</span>
                    <select class="tan_input tan_select" name="fid" id="rfid">
                        <option value="">选择楼层</option>
                        <{foreach from=$floors item=m key=n}>
                        <option value="<{$m.id}>"><{$m.num}></option>
                        <{/foreach}>
                    </select>
                </div>
                <div class="div_01">
                    <span>房型:</span>
                    <select class="tan_input tan_select" onchange="getPro()" name="tid" id="rtid">
                        <option value="">选择房型</option>
                        <{foreach from=$types item=k key=l}>
                        <option value="<{$k.id}>"><{$k.name}></option>
                        <{/foreach}>
                    </select>
                    <select class="tan_input tan_select" name="pid" id="rpid">
                    </select>
                    <span>分机:</span>
                    <input type="text" name="tel" id="rtel" class="tan_input">
                </div>
                <div class="div_01">
                    <span>状态:</span>
                    <span class="shiyong"><input type="radio" name="status" checked="checked" value="1">使用</span>
                    <span class="shiyong"><input type="radio" name="status" value="2">停用</span>
                </div>
                <div class="div_01 sheshi">
                    <span class="sheshi_span">配套设施:</span>
                    <div class="sheshi01">
                        <{foreach from=$facs item=y key=u}>
                        <span class="shiyong"><input type="checkbox" name="fac_list[]" value="<{$y.id}>"><{$y.name}><i onclick="delfac(<{$y.id}>,this)" class="close_f_x"></i></span>
                        <{/foreach}>
                        <span class="zidingyi_box"><input type="text" value="自定义" class="zidingyi"><input type="button" value="+" class="input_jia"></span>
                    </div>

                </div>
                <div class="div_02 div_01">
                    <p style="p_position">备注:</p>
                    <textarea type="text" name="remark" id="rremark" class="tan_input"></textarea>
                </div>
                <input type="hidden" value="2" name="linktype"/>
                <div class="button">
                    <button class="button01" type="submit">保存</button>
                    <a class="quxiao">取消</a>
                </div>
            </div>
        </div>
    </div>
</form>
</div>
<script>
    var fid = 0,tid = 0;
    <{if isset($pam.fid) && $pam.fid!='0'}>fid=parseInt(<{$pam.fid}>);<{/if}>
    <{if isset($pam.tid) && $pam.tid!='0'}>tid=parseInt(<{$pam.tid}>);<{/if}>
    $('.house_ul>li>div:not(:last)').click(function () {
        var _this = $(this);
        _this.parent().parent().find('div').removeClass('add_active');
        _this.addClass('add_active');

        if (_this.parent().parent().hasClass('xianshi_01')){
            if (_this.parent().attr('id'))
                fid = _this.parent().attr('id').replace('f_','');
            else
                fid = 0;
        }else{
            if (_this.parent().attr('id'))
                tid = _this.parent().attr('id').replace('t_','');
            else
                tid = 0;
        }
        var url = '?m=manage&a=getRoomsByTid&tid='+tid+'&fid='+fid;
        window.location.href=url;

    })
    $('.xianshi_02>li:not(:first) .close_x').click(function(){
        var _this = $(this),
                tid = _this.parent().parent().attr('id').replace('t_',''),
                url = '?m=manage&a=delHotelType&tid='+tid;
        $.get(url,function(data){
            if(data.stat==1){
                alert(data.msg);
               // _this.parent().parent().remove();
                window.location.reload();
            }else{
                alert(data.msg);return;
            }
        },'json');
        return false;
    })
    $('.xianshi_03>li .close_x').click(function(){
        var _this = $(this),
                rid = _this.parent().parent().attr('id').replace('r_',''),
                url = '?m=manage&a=delRoom&rid='+rid;
        $.get(url,function(data){
            alert(data);
            //_this.parent().parent().remove();
            window.location.reload();
        });
        return false;
    });

    function getPro(){
        var tid = $('#rtid').val();
        var url = '?m=order&a=getProByTid&tid='+tid;
        $.get(url,function(data){
            var tempstr = '<option value="">选择方案</option>';
            for(item in data.msg){
                tempstr+='<option value="'+data.msg[item].id+'">'+data.msg[item].name+'</option>';
            }
            $('#rpid').html(tempstr);
        },'json');
    }

    function formcheck(){
        var rpid = $('#rpid').val();
        if(!rpid){
            alert('请选择方案');return false;
        }
        var rfid = $('#rfid').val();
        if(!rfid){
            alert('请选择楼层');return false;
        }
    }

    function delfac(id,o){
        var url = '?m=manage&a=delfac&id='+id;
        $.get(url,function(data){
            alert(data);
            $(o).parent().remove();
        });
    }
	function getheigth(obj,pop){
		$(pop).show();
		var t = parseInt($(obj).offset().top - $(pop).find('.floor_tan').height()/2);
		$(pop).find('.floor_tan').css({
			top : t
		});
	}
	$('.popup .quxiao').click(function(){
		$('.popup').hide();
	})

</script>
</body>
</html>
